#include "fig_boss_destoryer.h"
#include "fighter.h"
#include "fig_bullet.h"
#include "fig_enemybullet_master.h"
#include "fig_player_craft.h"
#include "fig_sounds.h"
#include "fig_boss_attackmove_manager.h"

#include "num/rand.h"
#include "math/facing.h"
#include "dd/dd_man.h"

FIGBossDestoryer::FIGBossDestoryer(FIGEnemyCraft::ENEMY_TYPES EnemyType) : 
								FIGEnemyBoss(											
											EnemyType
											)
								
{
	m_ShootCounter.SetLimit(3.0f);	
	m_ShootCounter.ForceReady();

	//testing
	//m_Life = 1;
}


void			FIGBossDestoryer::OnShootStyle1()
{

	if(num::RAND32::Instance().RandInt(0,3) == 0)	
			FIGBossAttackMoveManager::Instance().Start(
									FIGBossAttackMoveManager::ATTACK_MOVEMENT_CIRCLE, 
									0.0f);

	int C = 30;	
	for(int i = 0; i < C; i++)
	{
		FIGEnemyBulletMaster::Instance().Shoot(
											this,
											m_Bone.GetPosByWayPoint(0),
											FIGEnemyBulletMaster::BULLET_TYPE_LONG_RED,
											FIGBullet::SHOOT_STYLES_SINGLE,
											180,		// degree
											i * 0.1f,
											false,
											NULL,
											false,
											FIGSounds::BOSS_SHOOT
          									);

		FIGEnemyBulletMaster::Instance().Shoot(
											this,
											m_Bone.GetPosByWayPoint(1),
											FIGEnemyBulletMaster::BULLET_TYPE_LONG_RED,
											FIGBullet::SHOOT_STYLES_SINGLE,
											180,		// degree
											i * 0.1f,
											false,
											NULL,
											false,
											FIGSounds::BOSS_SHOOT
          									);
	}


	C = 8;
	float Delay = 0.0f;
	for(int i = 0; i < C; i++)
	{
		Delay += (0.1f); 
		FIGEnemyBulletMaster::Instance().Shoot(
											this,
											m_Bone.GetPosByWayPoint(4),
											FIGEnemyBulletMaster::BULLET_TYPE_CIRCLE_TRIPPLELAYER,
											FIGBullet::SHOOT_STYLES_DOUBLE,
											(360.0f / (float)C) * i ,		// degree
											Delay,
											false,
											NULL,
											false,
											FIGSounds::BOSS_SHOOT
          									);
	}

	Delay  = 0.0f;
	for(int i = 0; i < C; i++)
	{
		Delay += (0.1f); 
		FIGEnemyBulletMaster::Instance().Shoot(
											this,
											m_Bone.GetPosByWayPoint(5),
											FIGEnemyBulletMaster::BULLET_TYPE_CIRCLE_TRIPPLELAYER,
											FIGBullet::SHOOT_STYLES_DOUBLE,
											(360.0f / (float)C) * i ,		// degree
											Delay,
											false,
											NULL,
											false,
											FIGSounds::BOSS_SHOOT
          									);
	}
	


}


void			FIGBossDestoryer::OnShootStyle2()
{
	
	int C = 10;
	float Delay = 0.0f;

	for(int j = 0; j < 2; j++)
	{
		for(int i = 0; i < C; i++)
		{
			Delay += (0.1f); 
			FIGEnemyBulletMaster::Instance().Shoot(
												this,
												m_Bone.GetPosByWayPoint(4),
												FIGEnemyBulletMaster::BULLET_TYPE_CIRCLE_DOUBLELAYER,
												FIGBullet::SHOOT_STYLES_SINGLE,
												(360.0f / (float)C) * i ,		// degree
												Delay,
												false,
												NULL,
												false,
												FIGSounds::BOSS_SHOOT
          										);
		}

		for(int i = 0; i < C; i++)
		{
			Delay += (0.1f); 
			FIGEnemyBulletMaster::Instance().Shoot(
												this,
												m_Bone.GetPosByWayPoint(5),
												FIGEnemyBulletMaster::BULLET_TYPE_CIRCLE_DOUBLELAYER,
												FIGBullet::SHOOT_STYLES_SINGLE,
												(360.0f / (float)C) * i ,		// degree
												Delay,
												false,
												NULL,
												false,
												FIGSounds::BOSS_SHOOT
          										);
		}
	}
}


 void			FIGBossDestoryer::OnShootStyle3()
 {
	for( int i = 0; i < 8; i++)
	{
		FIGEnemyBulletMaster::Instance().Shoot(
												this,
												m_Bone.GetPosByWayPoint(0),
												FIGEnemyBulletMaster::BULLET_TYPE_LONG_CYAN,
												FIGBullet::SHOOT_STYLES_SINGLE,
												0,		// degree
												i * 0.3f,		// delay
												true,
												NULL,
												false,
												FIGSounds::BOSS_SHOOT
          										);

		FIGEnemyBulletMaster::Instance().Shoot(
												this,
												m_Bone.GetPosByWayPoint(1),
												FIGEnemyBulletMaster::BULLET_TYPE_LONG_CYAN,
												FIGBullet::SHOOT_STYLES_SINGLE,
												0,		// degree
												i * 0.3f,		// delay
												true,
												NULL,
												false,
												FIGSounds::BOSS_SHOOT
          										);
		//----------------
		FIGEnemyBulletMaster::Instance().Shoot(
												this,
												m_Bone.GetPosByWayPoint(2),
												FIGEnemyBulletMaster::BULLET_TYPE_LONG_RED,
												FIGBullet::SHOOT_STYLES_SINGLE,
												0,		// degree
												i * 0.3f,		// delay
												true,
												NULL,
												false,
												FIGSounds::BOSS_SHOOT
          										);

		FIGEnemyBulletMaster::Instance().Shoot(
												this,
												m_Bone.GetPosByWayPoint(3),
												FIGEnemyBulletMaster::BULLET_TYPE_LONG_RED,
												FIGBullet::SHOOT_STYLES_SINGLE,
												0,		// degree
												i * 0.3f,		// delay
												true,
												NULL,
												false,
												FIGSounds::BOSS_SHOOT
          										);
	//----------------
		FIGEnemyBulletMaster::Instance().Shoot(
												this,
												m_Bone.GetPosByWayPoint(4),
												FIGEnemyBulletMaster::BULLET_TYPE_LONG_CYAN,
												FIGBullet::SHOOT_STYLES_SINGLE,
												0,		// degree
												i * 0.3f,		// delay
												true,
												NULL,
												false,
												FIGSounds::BOSS_SHOOT
          										);

		FIGEnemyBulletMaster::Instance().Shoot(
												this,
												m_Bone.GetPosByWayPoint(5),
												FIGEnemyBulletMaster::BULLET_TYPE_LONG_CYAN,
												FIGBullet::SHOOT_STYLES_SINGLE,
												0,		// degree
												i * 0.3f,		// delay
												true,
												NULL,
												false,
												FIGSounds::BOSS_SHOOT
          										);
		//----------------
		FIGEnemyBulletMaster::Instance().Shoot(
												this,
												m_Bone.GetPosByWayPoint(6),
												FIGEnemyBulletMaster::BULLET_TYPE_LONG_RED,
												FIGBullet::SHOOT_STYLES_SINGLE,
												0,		// degree
												i * 0.3f,		// delay
												true,
												NULL,
												false,
												FIGSounds::BOSS_SHOOT
          										);

		FIGEnemyBulletMaster::Instance().Shoot(
												this,
												m_Bone.GetPosByWayPoint(7),
												FIGEnemyBulletMaster::BULLET_TYPE_LONG_RED,
												FIGBullet::SHOOT_STYLES_SINGLE,
												0,		// degree
												i * 0.3f,		// delay
												true,
												NULL,
												false,
												FIGSounds::BOSS_SHOOT
          										);
	}
 
}


 void			FIGBossDestoryer::OnShootStyle4()
 {
	 int C = 5;
	
	if(num::RAND32::Instance().RandInt(1,2) == 1)
	{
		FIGBossAttackMoveManager::Instance().Start(
			FIGBossAttackMoveManager::ATTACK_MOVEMENT_RIGHT_AND_LEFT, 
			num::RAND32::Instance().RandFloat(0.0f,0.5f));	

		// reduce count
		C = 3;
	}

	
	float Delay = 0.0f;
	float StartDegree = num::RAND32::Instance().RandFloat(0.0f,359.0f);

	for(int j = 1; j <= 16; j++)
	{
		
		for(int i = 0; i < C; i++)
		{
			FIGEnemyBulletMaster::Instance().Shoot(
												this,
												m_Bone.GetPosByWayPoint(4),
												FIGEnemyBulletMaster::BULLET_TYPE_CIRCLE_DOUBLELAYER,
												FIGBullet::SHOOT_STYLES_DOUBLE,
												StartDegree + (360.0f / (float)C) * i ,		// degree
												Delay,
												false,
												NULL,
												false,
												FIGSounds::BOSS_SHOOT
          										);

			FIGEnemyBulletMaster::Instance().Shoot(
												this,
												m_Bone.GetPosByWayPoint(5),
												FIGEnemyBulletMaster::BULLET_TYPE_CIRCLE_DOUBLELAYER,
												FIGBullet::SHOOT_STYLES_DOUBLE,
												StartDegree + (360.0f / (float)C) * i ,		// degree
												Delay,
												false,
												NULL,
												false,
												FIGSounds::BOSS_SHOOT
          										);
		}
		if((j)%4== 0)
			Delay += 0.4f;
		else if((j)%2== 0)
			Delay += 0.2f;
		else
			Delay += 0.1f;
	}
 }





	